package com.af.data.jpa.entity;

import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;

/**
 * @author : zhenyun.su
 * @comment :
 * 子类若使用Lombok的@Data注解， 需添加@EqualsAndHashCode(callSuper = true)
 * @since : 2020/1/10
 */

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class AfAuditorCreate {
    @CreatedBy
    protected String createdBy;
    @CreatedDate
    protected LocalDateTime createdDate;

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public LocalDateTime getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(LocalDateTime createdDate) {
        this.createdDate = createdDate;
    }

    @Override
    public String toString() {
        return "AbstractCreate{" +
                "createdBy='" + createdBy + '\'' +
                ", createdDate=" + createdDate +
                '}';
    }
}
